package com.cq.xjms.web.actions.interceptor;

import com.cq.xjms.model.Student;
import com.cq.xjms.util.Constants;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.Interceptor;

/**
 * 学生权限拦截器基类
 * @author caiqiang
 * @version 1
 */
public class StudentLoginAuthInterceptor implements Interceptor {

	private static final long serialVersionUID = 4172679552892871788L;

	public String intercept(ActionInvocation invocation) throws Exception {

		ActionContext invocationContext = invocation.getInvocationContext();
		
		if(invocationContext.getActionInvocation().getProxy().getMethod().equals("index")||invocationContext.getActionInvocation().getProxy().getMethod().equals("login")||invocationContext.getActionInvocation().getProxy().getMethod().equals("logout")){
			return invocation.invoke();
		}
		Student student = (Student)invocationContext.getSession().get(Constants.LOGIN_STUDENT);
		if (student == null) {
			return "login";
		}
		return invocation.invoke();
	}

	@Override
	public void destroy() {
		
	}

	@Override
	public void init() {
		
	}
	

}
